<?php
$intCustomerID 		= 	$_REQUEST["intCustomerID"];
$txtFromName 	= 	SERVER_NAME;
//$intMarketingCampaignID = $myrow[Campaign];
//include (MODULE . "/action/qrySelectMarketingCampaign_Class");<br/>
if(isset($_REQUEST["intSupplierID"]))
{
	//Use passed through variables as we are sending an email to the supplier	
	include (MODULE . "/action/qrySelectSupplier");
	
	if($intPromotionalItem == 1)
		$strSpecialOrder = " (European range) ";
	else
		$strSpecialOrder = " (UK range) ";
		
	//$txtFromName		= $_REQUEST["txtFromName"];
	$txtEmailTo			= $myrow['Email'];
	$intOrder			= $_REQUEST['intOrderHeaderID']; 
	$txtSubject			= "Stock enquiry - Model: ".$_REQUEST["strSupplierProduct"].", Quantity: ".$_REQUEST["intQuantity"].$strSpecialOrder." Order: ".$intOrder;
	$txtEmailContent 	= "Please allocate stock of ".$_REQUEST["intQuantity"]." x ".$_REQUEST["strSupplierProduct"].$strSpecialOrder." for order ".$intOrder.".&#013;Thank You";
	$txtReplyEmail 		= "stockcheck@".WEB_DOMAIN;
	include (MODULE . "/action/qrySelectCustomer");
}else{
	include (MODULE . "/action/qrySelectCustomer");
	$strFormName 	= 	"frmEmailCustomer";
	$strTitle		=	"Email Client";
	$txtSubject 	= 	"";
	$txtEmailTo		=	$myrow['Email'];
	$txtReplyEmail 		= 	$_SESSION['sesUserName'];
	$txtEmailCC 		= 	$_SESSION['sesUserName'];
	$txtEmailContent = DisplayLookupValue("tblTitle","Title",$myrow['Title'])."&nbsp;".$myrow['FirstName']."&nbsp;".$myrow['Surname']."&#013;";
}

//if customer has subscribed to the CRM package allow screen to process else
//send customer to CRM message screen
if(CRM == true){
	$strScreenName 	= 	"DisplayCustomer";
	$strQueryName	=	"actEmailCustomer";
}else{
	$strScreenName 	= 	"NoCRM";
	$strQueryName	=	"";
}?>


 <tr>
     <td><?=
     	(StartForm($strScreenName, "post", $strQueryName,array('strSearching'=>"True",'intCustomerID'=>$intCustomerID),"","",$strFormName,""));?>
		<table  width='450' cellpadding='0' cellspacing='0' border='0' class='Normal' align='center'><?

		if(!$txtEmailTo)
		{?>

			<tr>
		         <td align='center' colspan='2'>
				 	<b>This record has no email address.</b><br/>Update main record and try again.
				</td>
		    </tr><?		
		}else{?>
			<tr>
				<td colspan='2'>
					<b>Email </b>
				</td>
			</tr>			
			<tr>
		         <td align='left' colspan='1'>
				 	<b>From&nbsp;(Name):&nbsp;</b>
				</td>
				<td align='right'>
					<input type="text" name="txtFromName" value='<?echo $txtFromName?>' size= "45" maxlength="70"/>
				</td>
		
		     </tr>
			 
			 <tr>
			 	<td align='left' colspan='1'>
					<b>To :&nbsp;</b>
				</td>
				<td align='right'>
					<input type="text" name="txtEmailTo" value = '<?=$txtEmailTo?>' size= "45" maxlength="70"/>
				</td>
			</tr>
			
			 <tr>
			 	<td align='left' colspan='1'>
					<b>Reply Email :&nbsp;</b>
				</td>
				<td align='right'>
					<input type="text" name="txtReplyEmail" value = '<?echo $txtReplyEmail?>' size= "45" maxlength="70"/>
				</td>
			</tr>

			 <tr>
		         <td align='left' colspan='1'>
		             <b>Subject :&nbsp;</b>
		         </td>
		         <td align='right' colspan='1'>
		             <input type="text" name="txtSubject" value = '<?echo $txtSubject?>' size= "45" maxlength="100"/>
		         </td>
		     </tr>
			 
			 <tr>
		         <td align='left' colspan='1'>
		             <b>BCC :&nbsp;</b>
		         </td>
		         <td align='right' colspan='1'>
		             <input type="text" name="txtEmailCC" value = '<?echo $txtEmailCC?>' size= "45" maxlength="100"/>
		         </td>
		     </tr>
			<tr>
					<td colspan='2'>
						<textarea cols='54' rows='10' name='txtEmailContent'><?=$txtEmailContent?></textarea>
					</td>
			</tr>

			<tr>
				<td align='right' colspan='2'>
					<input type='submit' value='Send'/>
				</td>
			</tr><?
		}?>
		</table><?="
		</form>";?>
	</td>
</tr>

